<template>
	<view>
		<view style="margin-bottom: 80upx;padding-top: 100rpx;" >	
			  <view class="search">
			  	<view>
					<input type="text" v-model="vals" placeholder="请搜索商品" @confirm="search">
				</view>
				<text @click="search">搜索</text>
			  </view>
				<block v-for="(value,key) in shoparr" :key="key">
				<view @click="detail(value.id)" style="position: relative;" class="box pd12_10 flex alcenter mb16 hezi" >
					<image mode="aspectFill" class="tuan-product-l" :src="value.img"></image>
					<!-- <view class="btn-mini" style="position: absolute; top: 40upx; left: 280upx; border-radius: 10upx;font-size: 18upx;width: 60upx; height: 36upx;" :style="getBtnStyle">{{value.lxname}}</view> -->
					<view class="tuan-product-r pl15">
						<view class="ft14 cl-main text-over2">{{value.title}}</view>
						<view class="ft12 cl-notice text-over2">{{value.introduce}}</view>
						<view class="mt10">
							<text class="mr5 ft14 cl-orange ftw600">¥{{value.money}}</text>
							<text class="ml5 ft10 cl-notice text-line">¥{{value.money_primary}}</text>
						</view>
						<view class="mt10 flex space alcenter">
							<text class="ft12 cl-notice" v-if="value.stock">库存 {{value.stock}}</text>
							<text  class="coupon-tip" style="float: right;background: none;color: #363B4D;" v-if="value.sales">销量{{value.sales}}</text>
						</view>
						<view class="mt10 flex space alcenter" v-if="value.end_time_text">
							<view class="ft12 cl-orange cl-notice">{{value.end_time_text}}</view>
						</view>
					</view>
				</view>
				</block>
				<empty v-if="shoparr.length === 0 && kong"></empty>
		</view>
	</view>
</template>

<script>
	import empty from "@/components/empty";
	export default{
		components:{
			empty
		},
		data(){
			return {
				isLogin:false,
				showBirthday:false,
				showLogin:false,
				showQrcode:false,
				showCouponShareGet:false,
				TabCur: 0,
				scrollLeft: 0,
				shoparr:[],
				page:1,
				vals:'',
				kong:false
			}
		},

		onReachBottom(){
			this.page++;
			this.search()
		},
		methods:{
			search(){
				this.$ajax('post','goods/search',{
					page:this.page,
					keyword:this.vals
				}).then(res=>{
					this.shoparr.push(...res.data)
					if(this.shoparr.length==0){
						this.kong=true
					}else{
						this.kong=false
					}
				})
			},
			detail(id,lx){
				uni.navigateTo({
					url:'/pages/client/shop/product?id='+id
				})
			},
			showLoginAct(){
				this.showLogin = true;
			},
			showLoginCouponShareGet(){
				this.showLogin = true;
			},
			loginYes(){
				
			}
		}
	}
</script>

<style lang="scss">
	.search{
		width: 100%;
		position: fixed;
		top: 0;
		left: 0;
		height: 100rpx;
		background: #fff;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 10rpx 20rpx;
		z-index: 3;
		>view{
			width: 85%;
			background: #F7F7F7;
			height: 80rpx;
			border-radius:40rpx ;
			input{
				width: 100%;
				height: 100%;
				padding-left: 20rpx;
				font-size: 32rpx;
			}
		}
		>text{
			background: #01B750;
			width: 15%;
			height: 60rpx;
			text-align: center;
			align-items: center;
			display: flex;
			justify-content: center;
			font-size: 32rpx;
			border-radius: 30rpx;
			color: #fff;
		}
	}
	.nav .cu-item.cur {
		border-bottom: 4upx solid;
	}
	
	.nav .cu-item {
		height: 90upx;
		display: inline-block;
		line-height: 90upx;
		margin: 0 10upx;
		padding: 0 20upx;
	}
	.text-green{
		color: rgb(1, 183, 80);
	}
	.nav .cu-item.cur {
		border-bottom: 4upx solid;
	}
	.nav {
		background: #fff;
		white-space: nowrap;
	}
	.home-header{
		height: 304rpx;
		width: 100%;
		position: relative;
		background: #363B4D;
		border-radius: 0rpx 0rpx 48rpx 48rpx;
	}
	.hezi{
		width: 92%;
		margin: 30rpx auto 0;
	}
	.home-main{
		width: 100%;
		position: relative;
		margin-top: -156rpx;
		padding: 0 30rpx;
	}
	.home-mendian{
		width: 100%;
		height: 84rpx;
		background:rgba(255,255,255,0.1);
		border-radius: 42rpx;
	}
	.tuan-product-l{
		width: 240rpx;
		height: 240rpx;
		border-radius: 16rpx;
		background: #F2F2F2;
	}
	.tuan-product-r{
		width: calc(100% - 240rpx);
	}
	
</style>
